<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="description" content="Real Estate Builders Free Responsive Website Templates - icon">
	<meta name="author" content="webThemez.com">
	<title>欢迎来到拴马桩</title>
	<link rel="favicon" href="assets/images/favicon.png">
	<link rel="stylesheet" media="screen" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,700">
	<link rel="stylesheet" href="assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="assets/css/font-awesome.min.css">
	<link rel="stylesheet" href="assets/css/bootstrap-theme.css" media="screen">
	<link rel="stylesheet" href="assets/css/style.css">
	<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
	<script th:src="@{/webjars/jquery/3.6.0/dist/jquery.js}"></script>
	<link rel="shortcut icon" href="Imperial/assets/img/logo.php">
	<link rel="stylesheet" type="text/css" href="assets/css/ShoppingCart.css"/>
	<link rel="stylesheet" th:href="@{/webjars/layui/2.5.7/css/layui.css}">
	<script th:src="@{/webjars/layui/2.5.7/layui.js}"></script>
</head>

<body >
	<!-- Fixed navbar -->
	<div th:replace="~{commons/commons::topbar(active='services')}"></div>
	<!-- /.navbar -->

	<header id="head" class="secondary">
		<div class="container">
			<div class="row">
				<div class="col-sm-8">
					<h1>Services</h1>
				</div>
			</div>
		</div>
	</header>
	<link rel="canonical" href="https://bj.lianjia.com/yezhu/maifang/"/>
	<link rel="stylesheet" href="https://s1.ljcdn.com/feroot/pc/asset/yezhu/maifang/index.css?_v=20210727193349819">
	<div th:switch="${msg}">
	<form th:case="1" class="layui-form" >
		<br>
		<br>
		<div class="g-main" style="padding-bottom:0;margin-bottom:-45px;height: 100px"><div style="height: 100px" class="m-jumbotron"><div class="tit" >发布车位</div></div>
			<div class="m-form">
			<div class="box-l m-entry">
				<dl class="compact">
					<dt>车位所在城市</dt>
					<dd>
						<!-- <div>北京</div> -->
						<div class="u-sug">
							<input th:value="${userOwner.city}" readonly class="sugInput" id="city" type="text" autocomplete="off" placeholder="请输入车位所在城市" required/>
							<ul></ul>
						</div>
					</dd>
				</dl>
				<dl>
					<dt>车位所在地址</dt>
					<dd class="wrap-sug">
						<div class="u-sug">
							<input th:value="${userOwner.address}" readonly class="sugInput" id="address" type="text" autocomplete="off" placeholder="请输入车位地址" required/>
							<ul></ul>
						</div>
					</dd>
				</dl>

				<dl>
					<dt>车位编号</dt>
					<dd class="wrap-sug">
						<div class="u-sug">
							<input  class="sugInput" id="number" type="text" autocomplete="off" placeholder="请输入车位编号" required/>
							<ul></ul>
						</div>
					</dd>
				</dl>

				<dl>
					<dt>开盘情况</dt>
					<dd class="wrap-sug">
						<div class="u-sug">
							<input  class="sugInput" id="open" type="text" autocomplete="off" placeholder="请输入'是'或'否'" required/>
							<ul></ul>
						</div>
					</dd>
				</dl>
				<dl>
					<dt>车位说明</dt>
					<dd class="wrap-sug">
						<div class="u-sug">
							<input class="sugInput" id="explain" type="text" autocomplete="off" placeholder="请输入车位说明" required/>
							<ul></ul>
						</div>
					</dd>
				</dl>
				<dl>
					<dt>车位图片上传</dt>
					<div class="layui-input-block">
						<button type="button" class="layui-btn" id="upload">
							<i class="layui-icon">&#xe67c;</i>上传图片
						</button>
					</div>
				</dl>
				<dl style="display: none" id="imageControl">
					<dt>图片预览</dt>
					<div class="layui-input-block" id="imagedisplay">
							<img id="image" style="width: 300px;height: 300px">
					</div>
				</dl>
				<dl>
					<dt>期望售价</dt>
					<dd>
						<input id="price" value="" type="text" placeholder="请输入您期望卖出的价格" autoComplete="off" style="width: 210px;" required/>
						<div class="unit">元</div>
					</dd>
				</dl>

			</div>
				<br>
				<br>
				<br>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" th:align="center" style="margin-left:350px" onclick="sub()" type="button">立即提交</button>
				</div>
			</div>
			</div>
		</div>
	</form>
		<h1 th:case="业主身份待审核" align="center"><br><br><br>业主身份待审核</h1>
		<h1 th:case="你不是业主" align="center"><br><br><br>你不是业主，请认证业主</h1>
	</div>
</body>
</html>
<script>
	function sub(){
		let flag=confirm("是否提交");
		if (flag==true){
				let city=$("#city").val();
				let address=$("#address").val();
				let number=$("#number").val();
				let price=$("#price").val();
				let open=$("#open").val();
				let explain=$("#explain").val();
				if(city==null||city.trim()==""||city==""){
					layui.use('layer',function () {
						layer.msg("提交不能有空行");
					})

				}
				else if(address==null||address.trim()==""||address==""){
					layui.use('layer',function () {
						layer.msg("提交不能有空行");
					})
				}
				else if(number==null||number.trim()==""||number==""){
					layui.use('layer',function () {
						layer.msg("提交不能有空行");
					})
				}
				else if(price==null||price.trim()==""||price==""){
					layui.use('layer',function () {
						layer.msg("提交不能有空行");
					})
				}
				else if(open==null||open.trim()==""||open==""){
					layui.use('layer',function () {
						layer.msg("提交不能有空行");
					})
				}
				else if(explain==null||explain.trim()==""||explain==""){
					layui.use('layer',function () {
						layer.msg("提交不能有空行");
					})
				}
				else{
					$.post({
						url:'/addParkingLot',
						data:{
							"city":city,
							"address":address,
							"number":number,
							"price":price,
							"open":open,
							"explain":explain
						},
						success:function (res) {
							layui.use('layer',function () {
								layer.msg(res);
							})
						}
					})
				}
		}
	}
	layui.use('upload', function(){
		let upload = layui.upload;
		let $=layui.$;
		//执行实例
		let uploadInst = upload.render({
			elem: '#upload' //绑定元素
			,url: '/uploadImage' //上传接口
			,done: function(res){
				//上传完毕回调
				$("#imageControl").attr("style","display: block");
				let imagepath=res.map.src;
				$("#image").attr("src",imagepath);
				layer.msg("上传成功");
			}
			,error: function(){
				//请求异常回调
			}
		});
	});
</script>
